home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / msysjour / vol06 / 04 / winstdio / simple3.c < prev    next >
C/C++ Source or Header  |  1991-07-01  |  1KB  |  57 lines

  1. /*
  2. SIMPLE3.C
  3.  
  4. Microsoft C, Windows SDK:
  5. cl -c -AS -Gsw -Oais -Zpe simple3.c winio.c wmhandlr.c
  6. link simple3 winio wmhandlr,simple3,nul,/nod slibcew libw,winio.def
  7. rc winio.rc simple3.exe
  8.  
  9. Borland C++:
  10. bcc -WS -G -O -Z -w-par -Hu simple3.c winio.c wmhandlr.c
  11. copy winio.rc simple3.rc
  12. rc winio.rc simple3.exe
  13. */
  14.  
  15. #include "windows.h"
  16. #include "winio.h"
  17.  
  18. unsigned num_tasks=0;
  19.  
  20. void show_info(void)
  21. {
  22.     unsigned vers = GetVersion();
  23.     unsigned long flags = GetWinFlags();
  24.     num_tasks = GetNumTasks();
  25.     winio_clear();
  26.     printf("Windows v. %d.%d\n", LOBYTE(vers), HIBYTE(vers));
  27.     printf("%s mode\n", 
  28.         (flags & WF_ENHANCED) ? "Enhanced" :
  29.         (flags & WF_STANDARD) ? "Standard" :
  30.         /* default */           "Real");
  31.     printf("%d tasks running\n", num_tasks);
  32. }
  33.  
  34. long on_time(HWND hwnd, unsigned message, WORD wParam, LONG lParam)
  35. {
  36.     if (GetNumTasks() != num_tasks)
  37.         show_info();
  38.     return 0;
  39. }
  40.  
  41. int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, 
  42.     LPSTR lpCmdLine, int nCmdShow)
  43. {
  44.     winio_settitle("Introduction to WINIO, with Timer");
  45.     if (! winio_init(hInstance, hPrevInstance, nCmdShow, 0))
  46.         return 1;
  47.     wmhandler_set(WM_TIMER, on_time);
  48.     if (! SetTimer(winio_hwnd(), 1, 1000, NULL)) // once a second
  49.     {
  50.         winio_warn(FALSE, "can't create timer");
  51.         winio_close();
  52.     }
  53.     
  54.     return 0;
  55. }
  56.  
  57.